// https://vuex.vuejs.org/zh-cn/intro.html
// make sure to call Vue.use(Vuex) if using a module system
import Vue from 'vue'
import Vuex from 'vuex'
import friendBattleStroe from './friendBattle'
Vue.use(Vuex)

const store = new Vuex.Store({
  namespaced:true,
  state: {
    appInfo:{},//版本信息 + 用户id
    isAuthorize:false,
    IMGHEAD: "https://ggbsq.xingpanwang.com/renren-fast/smallUploadSource",//图片地址前缀
    // IMGHEAD: "http://192.168.2.238:8012",//图片地址前缀
    SESSIONID: "",//登凭证
    openId:0,//socketId
    SCENE: 0,//场景值
    userInfo: {},//用户信息
    deviceInfo: {},//设备信息,
    socketState:0,//1连接，0关闭
    userOneState:false, //用户A 答题状态
    userTwoState:false,// 用户B 答题状态
    cw:0,//我的连胜场次
    gameRecord:{},//对局记录，回顾用
    // 排位
    isRank:false,
    dayCount:0,
    isDayChallenge:0,
  },
  mutations: {
    setOpenId(state,openId){
      state.openId = openId;
    },
    setIsDayChallenge(state,boolean){
        state.isDayChallenge = boolean;
    },
    setDayCount(state,count){
      state.dayCount = count;
    },
    setIsRank(state,value){
      state.isRank = value;
    },
    setGameRecord(state,record){
      state.gameRecord = record;
    },
    setCw(state,info){
      state.cw = info;
    },
    setUserOneState(state,type){
      state.userOneState = type;
    },
    setUserTwoState(state,type){
      state.userTwoState = type;
    },
    setSocketState(state,boolean){
      state.socketState =boolean;
    },
    setAppInfo(state, obj) {
      state.appInfo = obj;
    },
    setAppInfoByItem(state,obj){
      for (let item in obj){
        state.appInfo[item] = obj[item];
      }
    },
    setUserInfo(state, userInfo) {
      for (let item in userInfo){
        state.userInfo[item] = userInfo[item];
      }
      // state.userInfo = userInfo;
    },
    setAuthorize(state,boolean){
      state.isAuthorize = boolean;
    },
    setSessionId(state, id) {
      state.SESSIONID = id;
    },
    setDeviceInfo(state, info) {
      state.deviceInfo = info;
    },
    setScene(state, scene) {
      state.SCENE = scene;
    },
  },
  modules:{
    fStore:friendBattleStroe
  },

})

export default store
